<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>menu</title>
</head>
<body>
   <div id="customMenu">右键查看自定义的菜单</div>
    <ul id="rightMenu" style="display: none;position: fixed;">
        <li>菜单一</li>
        <li>菜单二</li>
        <li>菜单三</li>
    </ul>
    <a id="nav" href="http://www.baidu.com">百度</a>
    <script>
        let customMenu = document.getElementById('customMenu');
        let rightMenu = document.getElementById('rightMenu');
        let nav = document.getElementById('nav');
        document.addEventListener('contextmenu',function(event){
            ///event.preventDefault();
            rightMenu.style.display = 'block';
            rightMenu.style.top = event.clientY+'px'
            rightMenu.style.left = event.clientX+'px'
        });
        document.addEventListener('click',()=>{
            rightMenu.style.display = 'none';
        });
        nav.addEventListener('click',function(event){
            event.preventDefault();
            alert('click');
        });
    </script>
</body>
</html>